package org.despair2D.ui.puppet.supportClasses 
{
	import flash.events.Event;
	import org.despair2D.core.EventDispatcherAdvance;
	import org.despair2D.ui.core.Component;
	import org.despair2D.ui.core.FusionComp;
	import org.despair2D.ui.core.ComponentProxy;
	
	import org.despair2D.core.ns_despair;
	use namespace ns_despair;
	
public class PuppetComp extends Component
{
	
	final ns_despair function set proxy( v:ComponentProxy ) : void
	{
		m_proxy            =  v;
		m_eventDispatcher  =  new EventDispatcherAdvance(m_proxy);
	}
	
	final ns_despair function get interactiveZ () : Boolean
	{
		var FC:FusionComp;
		
		if (this.interactive)
		{
			FC = this.parent as FusionComp
			while (FC)
			{
				if (!FC.interactive)
				{
					return false;
				}
				FC = FC.parent as FusionComp;
			}
			return true;
		}
		return false;
	}
	
	final ns_despair function bubble( event:Event ) : void
	{
		var FC:FusionComp
		
		this.dispatchEvent(event)
		FC = this.parent as FusionComp;
		while (FC)
		{
			FC.dispatchEvent(event)
			FC = FC.parent as FusionComp;
		}	
	}
	
	
	ns_despair function makeTransform( smoothing:Boolean, external:Boolean ) : void
	{
	}
	
	ns_despair static function getPuppetComp() : PuppetComp
	{
		return (cachedPuppetCompLength > 0 ? cachedPuppetCompLength-- : 0) ? cachedPuppetCompList.pop() : new PuppetComp();
	}
	
	ns_despair function recycle() : void
	{
		cachedPuppetCompList[cachedPuppetCompLength++] = this;
	}
	
	
	ns_despair static var cachedPuppetCompList:Array = []
	
	ns_despair static var cachedPuppetCompLength:int;
}
}